//
// Created by yangy on 2018/6/28.
//

#ifndef SUPERAUDIOPLAYER_WIPREPAREDLISTENER_H
#define SUPERAUDIOPLAYER_WIPREPAREDLISTENER_H

#include <jni.h>
#define MAIN_THREAD 0
#define CHILD_THREAD 1

class JavaCallBack {

private:
    //java虚拟机类 用来获取JNIEnv对象 因为每个线程都有自己的env
    JavaVM *javaVM = NULL;
    //JNI环境对象
    JNIEnv * env = NULL;
    //回调对象 一般方法用jobject 静态方法用jclass
    jobject  listener_obj;
    //回调方法的id
    jmethodID  prepare_mid;

    jmethodID  load_mid;

    jmethodID  time_info_mid;

    jmethodID  error_mid;

    jmethodID  record_mid;
public:
    JavaCallBack(JavaVM *javaVM,JNIEnv * env,jobject  listener_obj);
    ~JavaCallBack();
    void onPrepared(int type);
    void onLoad(int type, bool load);
    void onTimeInfo(int type,int total,int current);
    void onError(int type,int code,char* msg);

    void onRecord(int type,int size,void* buffer);
};


#endif //SUPERAUDIOPLAYER_WIPREPAREDLISTENER_H
